package logic

import (
	"context"
	"member_srv/member"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ListUserLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewListUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListUserLogic {
	return &ListUserLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ListUserLogic) ListUser(req *types.ListUserRequest) (resp *types.Response, err error) {
	_, err = l.svcCtx.MemberSrv.ListUser(l.ctx, &member.ListUserRequest{Username: req.Username})
	if req.Username == "" {
		return &types.Response{
			Code: 500,
			Msg:  "账号不存在",
			Data: nil,
		}, nil
	}
	return &types.Response{
		Code: 200,
		Msg:  "账号存在",
		Data: nil,
	}, nil
}
